package com.ruoyi.common.annotation;

import com.ruoyi.common.validation.ValidLengthConstraintValidatorForCharSequence;
import com.ruoyi.common.validation.ValidLengthConstraintValidatorForNumber;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;

/**
 * @Classname Length
 * @Author: sunluquan
 * @Date: 2022/6/17 12:12
 * @Description TODO
 * 校验字符串、数值等长度是否符合
 */
@Target({ElementType.FIELD,ElementType.METHOD,ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Constraint(validatedBy = {ValidLengthConstraintValidatorForCharSequence.class, ValidLengthConstraintValidatorForNumber.class})
public @interface Length {

    int min() default 0;//最小长度

    int max() default Integer.MAX_VALUE;//最大长度

    String message() default "{org.hibernate.validator.constraints.Length.message}";

    Class<?>[] groups() default { };

    Class<? extends Payload>[] payload() default { };
}
